package com.tbit.utils;

import java.math.BigDecimal;
import java.text.DecimalFormat;

/**
 * @author MyWin E-mail:335918956@qq.com
 * @version 1.0
 * @createTime 2020-01-07 12:00
 */
public class DoubleUtils {
    public static Double doubleScale(Double d) {
        String tmp = Double.toString(d);
        BigDecimal bdOrder = new BigDecimal(tmp);
        return bdOrder.setScale(2, BigDecimal.ROUND_DOWN).doubleValue();
    }

    public static double format(long num) {
        return (double) num / 100;
    }

    public static void main(String[] args) {
        System.out.println(doubleScale((double) 9 / 100));
    }


    public static Double toFloat(int denominator, int numerator) {
        // TODO 自动生成的方法存根
        DecimalFormat df = new DecimalFormat("0.00");//设置保留位数
        return Double.valueOf(df.format((float) denominator / numerator));
    }
}
